<template>
  <div>
    <div style="background: #e8f1f8">
      <div class="det_tab">
        <div style="text-align: center; margin: 10px">
          {{ form.CheckTaskName }}
        </div>
        <div class="det_tab_item">
          <eagle-cell-group :border="border">
            <eagle-input
              label="检查类型"
              :value="form.CheckTypeName"
              readonly
            ></eagle-input>
            <eagle-input
              label="来源计划"
              autosize
              type="textarea"
              rows="1"
              :value="form.CheckPlanName"
              readonly
              @click="goFromDetail()"
              :rightIcon="arrow"
            ></eagle-input>
            <eagle-input
              label="任务发起人"
              :value="form.CreateChnName"
              readonly
            ></eagle-input>

            <!-- <van-field
            label="来源"
            class="input_text"
            :value="
              form.OriginType == 1
                ? '检查表检查'
                : form.StatusName == 2
                ? '依据检查'
                : '随手拍'
            "
            readonly
          /> -->
            <eagle-input
              label="任务发起时间"
              :value="form.CreateDate"
              readonly
            />
            <eagle-input
              label="检查人"
              :value="form.CheckNames"
              readonly
            />
            <eagle-input
              label="检查时间段"
              rows="1"
              autosize
              type="textarea"
              :value="form.StartDate + '至' + form.EndDate"
              readonly
            />
            <eagle-input
              label="检查要求"
              :value="form.CheckRequirement"
              readonly
            />
            <eagle-input
              label="检查记录"
              :value="
                '隐患：' + form.HiddenDangerCnt + ' /检查：' + form.CheckCnt
              "
              right-icon="arrow"
              @click="goMyTaskHistoryList()"
              readonly
            />
            <eagle-input
              label="检查现场照片"
              :value="'已上传' + form.PhotoCnt + '张现场照片'"
              readonly
              right-icon="arrow"
              @click="goMyTaskFileList()"
            />
          </eagle-cell-group>
        </div>
      </div>
      <div class="det_tab" v-if="form.Templates.length > 0">
        <div class="det_tab_item">
          <div class="operate_det">
            <div style="margin-bottom: 10px">已分配的检查表</div>
            <div class="operate_list">
              <eagle-row
                v-for="(item, index) in form.Templates"
                :key="index"
                class="operate_row"
                @click="goCheckResult(item)"
              >
                <eagle-col span="1">{{ index + 1 }}</eagle-col>
                <eagle-col offset="1" span="18">{{ item.TName }} </eagle-col>
                <eagle-col span="4">
                  <eagle-tag v-if="item.Status == 10" size="mini" color="grey"
                    >已完成</eagle-tag
                  >
                </eagle-col>
              </eagle-row>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      baseUrl: process.env.VUE_APP_BASE_API,
      id: this.$route.query.id,
      border: false,
      form: {
        Templates: [],
      },
    };
  },
  filters: {
    formatDate: function (value, args) {
      var dt = new Date(value);
      var y = dt.getFullYear();
      var m = dt.getMonth() + 1;
      var d = dt.getDate();
      if (args.toLowerCase() === "yyy-mm-dd") {
        return `${y}-${m}-${d}`;
      } else {
        var hh = dt.getHours();
        var mm = dt.getMinutes();
        var ss = dt.getSeconds();
        return `${y}-${m}-${d}:${hh}:${mm}:${ss}`;
      }
    },
  },
  created() {
    this.geDetail();
  },
  activated() {
    // if (this.$route.params.Operator) {
    // 	this.CorrectiveUserName = this.$route.params.Operator
    // 	this.CorrectiveChnName = this.$route.params.OperatorName
    // }
  },
  methods: {
    goMyTaskFileList() {
      this.$router.push("/OtherDanger/DangerCheckTaskFileList?ctCode=" + this.form.CTCode);
    },

    goCheckResult(item) {
      this.$router.push(
        "/OtherDanger/DangerTemplateCheckResult?tCode=" + item.TCode + "&tRand=" + item.TRand
      );
    },
    goMyTaskHistoryList() {
      this.$router.push("/OtherDanger/DangerCheckTaskDetailList?ctCode=" + this.form.CTCode);
    },

    // 获取详情
    geDetail() {
      let _this = this;
      _this.$axios
      .get("/DangerCheckTask/GetDetail",{params:{ id: _this.id }})
      .then((res)=>{
        _this.form = res.data;
      })
    },
    goFromDetail(item) {
      this.$router.push("/OtherDanger/DangerCheckPlanView?cpId=" + this.form.CpID);
    },
  },
};
</script>

<style lang="less" scoped>
/*
        .main {
            height: 100vh;
        }
    */

.det_top_box {
  padding: 10px;
  background-color: #e8f1f8;
}

.detail_header {
  color: #ffffff;
  background: url("../../../assets/Images/AppIcon/image_riskunit_detail_bg.png");
  background-size: cover;
  padding: 10px;
  border-radius: 5px;
  /*background-color: #fff;*/

  .det_top {
    display: flex;
    justify-content: space-between;

    .dep_top_img {
      height: 20px;
      width: 20px;
      margin-right: 5px;
    }
  }

  .det_name {
    margin-top: 20px;
    text-align: center;
  }

  .det_location {
    text-align: center;
    margin-bottom: 20px;
  }
}

.det_tab {
  padding: 10px;
  .det_tab_item {
    padding: 10px 0;
    background-color: #fff;
    border-radius: 5px;
    margin-bottom: 10px;

    .det_tab_item_text {
      padding: 0 10px;
    }
  }
}
.text_box {
  padding: 10px;
  border-radius: 5px;
  /*background-color: #e8f1f8;*/
  margin-bottom: 10px;

  .text_top {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    .top_link {
      color: #1989fa;
    }
  }

  .text_item {
    display: flex;
    justify-content: space-between;
    margin-left: 10px;

    .item_link {
      color: #1989fa;
    }
  }

  .text_img {
    display: flex;
    align-items: center;

    .img_item {
      width: 33.3%;
      text-align: center;

      img {
        height: 25px;
        width: 25px;
        margin-bottom: 10px;
      }
    }
  }

  .text_history {
    display: flex;
    vertical-align: middle;
    margin-bottom: 10px;
  }

  .text_member {
    color: #1989fa;
    margin-bottom: 10px;
  }

  .text_total_img {
    display: flex;
    align-items: center;

    .img_item {
      width: 33.3%;
      text-align: center;

      .img_item_top {
        display: flex;
        vertical-align: middle;
        margin-bottom: 10px;
      }
      img {
        height: 15px;
        width: 15px;
        margin-right: 5px;
      }
    }
  }
  .text_record_list {
    .list_row {
      display: flex;
      justify-content: space-between;
      margin-bottom: 10px;
      > div {
        width: 33.3%;
      }
      .row_center {
        text-align: center;
      }
      .row_right {
        text-align: right;
      }
    }
  }
}
.operate_det {
  background-color: #fff;
  padding: 10px;
  .operate_list {
    font-size: 12px;
    border: 1px solid #e8f1f8;
    .operate_row_first {
      padding: 10px;
      background-color: #e8f1f8;
      border-bottom: 1px solid #e8f1f8;
      margin-bottom: 10px;
    }
    .operate_row {
      padding: 10px;
      border-bottom: 1px solid #e8f1f8;
      /*margin-bottom: 10px;*/
    }
  }
}
</style>
